package com.bestcem.xm.user.constant;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.Map;

/**
 * 公用常量
 *
 * @author panyun <yun.pan@idiaoyan.com>
 * @version v1.0
 * @date 2022/1/21 16:17
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CommonConstant {

    /**
     * 根据用户组根节点id获取该用户组及子用户组最大数量
     */
    public static final int CHILDREN_COUNT = 1000;
    /**
     * 默认返回错误码格式
     */
    public static final String ERROR_MSG_FORMATTER = "%s:%s";
    /**
     * 超时时间
     */
    public static final String MAIL_SMTP_TIMEOUT = "mail.smtp.timeout";
    /**
     * 验证
     */
    public static final String MAIL_SMTP_AUTH = "mail.smtp.auth";
    /**
     * 类
     */
    public static final String MAIL_SMTP_SOCKETFACTORY_CLASS = "mail.smtp.socketFactory.class";
    /**
     * 端口
     */
    public static final String MAIL_SMTP_SOCKETFACTORY_PORT = "mail.smtp.socketFactory.port";
    /**
     * 公司编码格式
     */
    public static final String ORG_CODE_FORMAT = "f%05d";
    /**
     * 倍市得咨询热线
     */
    public static final String BEST_HOTLINE = "400-618-8166 转 211";
    /**
     * 倍市得地址
     */
    public static final String SAAS_SERVER_URL = "https://xm-test.bestcem.com";
    /**
     * 邮件主题
     */
    public static final String EMAIL_SUBJECT = "提醒邮件";
    /**
     * List分批切割处理size
     */
    public static final int PARTITION_SIZE = 1000;

    /**
     * mq批量消息分批切割处理size
     */
    public static final int MQ_PARTITION_SIZE = 1000;

    /**
     * 全部权限
     */
    public static final String ALL_PERMISSION = "all";

    /**
     * # 系统显示文案
     */
    public static final String XM_NAME = "倍市得CEM";

    /**
     * 退订设置指定持续时间最小值
     */
    public static final int SPECIFIED_DURATION_MIN = 1;

    /**
     * 退订设置指定持续时间最大值
     */
    public static final int SPECIFIED_DURATION_MAX = 999;

    /**
     * 签名对应16进制字符串长度
     */
    public static final int SIG_HEX_LENGTH = 32;

    /**
     * 全部权限标注
     */
    public static final String ALL_PERIMISSION_CONSTANT = "*";

    /**
     * 双十一活动套餐名写死按套餐名匹配
     */
    public static final String TRIAL_1111_PACK_NAME = "专业版双十一特惠";

    public static final String ORDER_BUY_TYPE_DEFAULT = "default";
    public static final String ORDER_BUY_TYPE_TRIAL = "A001";
    public static final String ORDER_BUY_TYPE_DISCOUNT = "A002";

    /**
     * GrowingIO 登录用户变量上传API https://data.growingio.com/{ai}/loginUserId?auth={auth}
     */
    public static final String UPLOAD_USER_PROPERTY_URL = "https://data.growingio.com/{0}/loginUserId?auth={1}";

    /**
     * BIZ ZXWM URL
     */
    public static final String BIZ_ZXWM_URL = "/zxwm/";

    /**
     * BIZ TRAC URL
     */
    public static final String BIZ_TRACE_URL = "/trace/";

    /**
     * 问卷项目达到限额邮件相关参数模板
     */
    public static final String PROJECT_ANSWER_QUOTA_TIP = "您正在使用的{pack_name}套餐可创建个{total_quota}问卷项目，当前{rate_str}，升级套餐以创建更多。";
    public static final String PROJECT_REACHED_MAIL_SUBJECT = "【倍市得CEM】项目数到限额";
    public static final String PROJECT_COMING_UP_MAIL_SUBJECT = "【倍市得CEM】项目数即将到达限额";

    /**
     * 答卷达到限额邮件相关参数模板
     */
    public static final String RSPD_ANSWER_QUOTA_TIP = "您正在使用的{pack_name}套餐可收集{total_quota}份答卷，当前{rate_str}，升级套餐以收集更多。";
    public static final String RSPD_REACHED_MAIL_SUBJECT = "【倍市得CEM】答卷数到限额";
    public static final String RSPD_COMING_UP_MAIL_SUBJECT = "【倍市得CEM】答卷数即将到达限额";

    /**
     * 公司字符串参数与数据库字段的映射
     */
    public static final Map<String, String> ORG_FIELD_MAP = new HashMap<>();
    private static final String CONTENT = "content";
    private static final String STATUS = "status";

    static {
        ORG_FIELD_MAP.put("orgId", "org_id");
        ORG_FIELD_MAP.put("code", "code");
        ORG_FIELD_MAP.put("name", "name");
        ORG_FIELD_MAP.put(CONTENT, CONTENT);
        ORG_FIELD_MAP.put(STATUS, STATUS);
        ORG_FIELD_MAP.put("source", "source");
        ORG_FIELD_MAP.put("sourceRemark", "source_remark");
        ORG_FIELD_MAP.put("rootGroupId", "root_group_id");
        ORG_FIELD_MAP.put("industryId", "industry_id");
        ORG_FIELD_MAP.put("packageId", "package_id");
        ORG_FIELD_MAP.put("formalPackageId", "formal_package_id");
        ORG_FIELD_MAP.put("formalExpireTime", "formal_expire_time");
        ORG_FIELD_MAP.put("trialPackageId", "trial_package_id");
        ORG_FIELD_MAP.put("trialExpireTime", "trial_expire_time");
        ORG_FIELD_MAP.put("adminEmail", "admin_email");
        ORG_FIELD_MAP.put("adminPhone", "admin_phone");
        ORG_FIELD_MAP.put("packageExpireTime", "package_expire_time");
        ORG_FIELD_MAP.put("freeExpireTime", "free_expire_time");
        ORG_FIELD_MAP.put("skin", "skin");
        ORG_FIELD_MAP.put("publicKeyFilePath", "public_key_file_path");
        ORG_FIELD_MAP.put("privateKeyId", "private_key_id");
        ORG_FIELD_MAP.put("deliverCheckFlag", "deliver_check_flag");
        ORG_FIELD_MAP.put("completeFlag", "complete_flag");
        ORG_FIELD_MAP.put("adminName", "admin_name");
        ORG_FIELD_MAP.put("corpWallet", "corp_wallet");
        ORG_FIELD_MAP.put("smsPrice", "sms_price");
        ORG_FIELD_MAP.put("footer", "footer");
        ORG_FIELD_MAP.put("checkSmtpId", "check_smtp_id");
        ORG_FIELD_MAP.put("notifySalesFlag", "notify_sales_flag");
        ORG_FIELD_MAP.put("innerFlag", "inner_flag");
        ORG_FIELD_MAP.put("paasConf", "paas_conf");
        ORG_FIELD_MAP.put("distribution", "distribution");
        ORG_FIELD_MAP.put("deliveryAuthType", "delivery_auth_type");
        ORG_FIELD_MAP.put("contractUrls", "contract_urls");
        ORG_FIELD_MAP.put("parentId", "parent_id");
    }

    /**
     * 用户字符串参数与数据库字段的映射
     */
    public static final Map<String, String> USER_FIELD_MAP = new HashMap<>();

    static {
        USER_FIELD_MAP.put("userId", "user_id");
        USER_FIELD_MAP.put("orgId", "org_id");
        USER_FIELD_MAP.put("userName", "user_name");
        USER_FIELD_MAP.put("password", "password");
        USER_FIELD_MAP.put("salt", "salt");
        USER_FIELD_MAP.put("name", "name");
        USER_FIELD_MAP.put("avatar", "avatar");
        USER_FIELD_MAP.put("email", "email");
        USER_FIELD_MAP.put("phone", "phone");
        USER_FIELD_MAP.put(STATUS, STATUS);
        USER_FIELD_MAP.put(CONTENT, CONTENT);
        USER_FIELD_MAP.put("edition", "edition");
        USER_FIELD_MAP.put("showGuide", "show_guide");
        USER_FIELD_MAP.put("showVersion", "show_version");
        USER_FIELD_MAP.put("wxUnionid", "wx_unionid");
        USER_FIELD_MAP.put("wxMiniOpenid", "wx_mini_openid");
        USER_FIELD_MAP.put("wxOffiOpenid", "wx_offi_openid");
        USER_FIELD_MAP.put("wxNickname", "wx_nickname");
        USER_FIELD_MAP.put("fsOpenId", "fs_open_id");
        USER_FIELD_MAP.put("fsUnionId", "fs_union_id");
        USER_FIELD_MAP.put("fsName", "fs_name");
        USER_FIELD_MAP.put("qyWxUserid", "qy_wx_userid");
        USER_FIELD_MAP.put("qyWxOpenUserid", "qy_wx_open_userid");
        USER_FIELD_MAP.put("qyWxName", "qy_wx_name");
        USER_FIELD_MAP.put("dingUserid", "qy_wx_name");
        USER_FIELD_MAP.put("dingUnionid", "ding_unionid");
        USER_FIELD_MAP.put("dingName", "ding_name");
        USER_FIELD_MAP.put("ssoName", "sso_name");
        USER_FIELD_MAP.put("silentId", "silent_id");
        USER_FIELD_MAP.put("acceptFlag", "accept_flag");
        USER_FIELD_MAP.put("lastLoginTime", "last_login_time");
        USER_FIELD_MAP.put("registerIp", "register_ip");
        USER_FIELD_MAP.put("innerFlag", "inner_flag");
        USER_FIELD_MAP.put("showGuideRecords", "show_guide_records");
        USER_FIELD_MAP.put("userIndex", "user_index");
        USER_FIELD_MAP.put("biShareFlag", "bi_share_flag");
    }

    /**
     * 用于向系统商后台同步消息
     */
    public static final Map<String, String> NOTIFY_MAP = new HashMap<>();

    static {
        NOTIFY_MAP.put("USER:free_register", "注册");
        NOTIFY_MAP.put("USER:find_pwd", "找回密码");
        NOTIFY_MAP.put("USER:mobile_bind", "重置手机号");
        NOTIFY_MAP.put("USER:fast_login", "快速登录");
        NOTIFY_MAP.put("USER:Booking", "预约演示");
        NOTIFY_MAP.put("USER:biz", "biz预约");
        NOTIFY_MAP.put("USER:whitepaper_subscribe", "白皮书下载");
        NOTIFY_MAP.put("OPENPLATFORM:BOOKING", "合作伙伴留资");
    }
}
